<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var uniqueMorseRepresentations = function(words) {
    var map = new Map()
    map = {
        a:".-",
        b:"-...",
        c:"-.-.",
        d:"-..",
        e:".",
        f:"..-.",
        g:"--.",
        h:"....",
        i:"..",
        j:".---",
        k:"-.-",
        l:".-..",
        m:"--",
        n:"-.",
        o:"---",
        p:".--.",
        q:"--.-",
        r:".-.",
        s:"...",
        t:"-",
        u:"..-",
        v:"...-",
        w:".--",
        x:"-..-",
        y:"-.--",
        z:"--.."
    }

    console.log(map)
    let arr = []
    var s = ''
    for( var i = 0 ; i<words.length ; i++ ){
        for( var k = 0 ; k<words[i].length ; k++ ){
            s = s + map[words[i][k]]
        }
        arr.push(s)
        s = ''
    }
    let set = new Set(arr)
    return set.size
};

var words = ["gin", "zen", "gig", "msg"]
console.log(uniqueMorseRepresentations(words))
    </script>
</body>
</html>